<?php
namespace Home\Controller;

class InvestorQuestionController extends \Home\Controller\BaseController
{
	/**
	 * 添加问题
	 */
	public function addQuestion()
	{
		$param = I('params');
		$data['question'] = I('data.question', '', '', $param);
		$data['fund_id'] = I('data.fund_id', '', '/^\d+$/', $param);
		$data['user_id'] = $this->user['userId'];
		$data['mobile'] = $this->user['mobile'];
		$res = D('InvestorQuestion')->addQuestion($data);
		$this->ajaxReturn($res);
	}
	
	/**
	 * 查询提问
	 */
	public function questionList()
	{
		$param = I('params');
		//根据基金id查询
		if(I('data.fund_id', '', '/^\d+$/', $param)) {
			$where['fund_id'] = $param['fund_id'];
			
		//根据用户id查询
		} else {
			$where['user_id'] = $this->user['userId'];
		}
		
		$option = array();
		if(I('data.page', '', '/^\d+$/', $param) && I('data.size', '', '/^\d+$/', $param)) {
			$option['page'] = $param['page'];
			$option['size'] = $param['size'];
		}

		$res = D('InvestorQuestion')->searchQuestion($where, $option);
		$this->ajaxReturn($this->result($res));
	}
}